<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>web edit</title>
    <style>
        body {
            font: 12px 'Microsoft YaHei';
            padding: 0;
            margin: 0;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            color: #222;
        }
        
        #parentLeft ul,
        #parentRight ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        
        #parentLeft,
        #parentRight,
        #parentCenter {
            box-sizing: border-box;
        }
        
        #parentLeft {
            width: 300px;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
            background: #eee;
        }
        
        .childElement > .title,
        .propertyList > .title {
            padding: .3em 1em;
            box-sizing: border-box;
            font-size: 1.5em;
            color: #000;
            border-bottom: 1px solid gray;
        }
        
        .childElement > ul > li {
            width: 65px;
            height: 65px;
            border-radius: 4px;
            line-height: 65px;
            text-align: center;
            float: left;
            margin: 5px 5px;
            border: 1px solid lightgray;
            box-sizing: border-box;
            -moz-user-select: none;
            -webkit-user-select: none;
            user-select: none;
        }
        
        #parentCenter {
            position: absolute;
            left: 300px;
            top: 0;
            height: 100%;
            right: 250px;
            background: #ddd;
        }
        
        #editArea {
            width: 320px;
            height: 480px;
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
            border: 1px solid gray;
            box-shadow: 4px 4px 8px rgba(0, 0, 0, .5);
            background: #fff;
            overflow: auto;
        }
        
        #parentRight {
            position: absolute;
            width: 250px;
            right: 0px;
            height: 100%;
            top: 0;
            background: #eee;
            text-align: center;
        }
        
        .propertyList > ul > li {
            padding: .3em;
            position: relative;
            border-bottom: 1px solid lightgray;
            padding-left: 70px;
        }
        
        .label {
            position: absolute;
            left: 10px;
            top: .55em;
        }
        
        .input {
            display: block;
            width: 100%;
            height: 1.5em;
            box-sizing: border-box;
        }
        
        .preLocation {
            height: 50px;
            background: lightgray;
        }

        .createElement {
            border: 1px solid lightgray;
            padding: 1em;
            position: relative;
        }

        .createElement .set {
            width: 20px;
            height: 20px;
            position: absolute;
            right: 40px;
            top: 0;
            bottom: 0;
            margin: auto;
            border-radius: 50%;
            background: green;
        }

        .createElement .minus {
            width: 20px;
            height: 20px;
            position: absolute;
            right: 10px;
            top: 0;
            bottom: 0;
            margin: auto;
            border-radius: 50%;
            background: red;
        }

        .topAble {
            background-color: aqua;
        }

        .bottomAble {
            background-color: blue;
        }
    </style>
</head>

<body>
    <div id="parentLeft">
        <div class="childElement">
            <div class="title">基本元素</div>
            <ul>
                <li draggable="true" data-name="div" data-type="1">文字</li>
                <li draggable="true" data-name="img" data-type="1">图片</li>
                <li draggable="true" data-name="table" data-type="1">表格</li>
            </ul>
        </div>
    </div>
    <div id="parentCenter">
        <div id="editArea">
            <div class="preLocation">
                <svg viewBox="0 0 320 50">
                    <polygon points="145 21 156 21 156 10 164 10 164 21 175 21 175 29 164 29 164 40 156 40 156 29 145 29" fill="gray" />
                </svg>
            </div>
        </div>
        <div id="editElement"></div>
    </div>
    <div id="parentRight">
        <div class="propertyList">
            <div class="title">基本布局</div>
            <ul>
                <li>
                    <label class="label" for="location">文字布局:</label>
                    <select class="input" id="location">
                        <option value="0">left</option>
                        <option value="1">right</option>
                    </select>
                </li>
            </ul>
        </div>
    </div>
    <script src="./javascripts/dragEvent.js"></script>
    <script src="./javascripts/elementConfig.js"></script>
    <script>
        var dragLiList = document.querySelectorAll(".childElement>ul>li");
        var editArea = document.getElementById("editArea");
        var preLocation = document.querySelector(".preLocation");
        var parentList = document.querySelector("#parentLeft, #parentCenter, #parentRight");

        [].forEach.call(dragLiList, function (li) {
            li.addEventListener("dragstart", DragEvent.dragStartHandler, false);
            li.addEventListener("dragend", DragEvent.dragEndHandler, false);
        });

        editArea.addEventListener("drop", DragEvent.dropHandler, false);
        editArea.addEventListener("dragenter", DragEvent.dragEnterHandler, false);
        editArea.addEventListener("dragover", DragEvent.canDragOverHandler, false);
        editArea.addEventListener("dragleave", DragEvent.dragLeaveHandler, false);

        [].forEach.call(parentList, function(parent) {
            parent.addEventListener("dragover", DragEvent.cantDragOverHandler, false);
            parent.addEventListener("drop", DragEvent.cantDropHandler, false);
        });
    </script>
</body>

</html>